public class testdeleteRegionList  {
    
    static testMethod void testTrigger() {
        Profile p  = [select id from profile where name=: 'System Administrator'];   //id =:UserInfo.getProfileId()];      
         User u3 =new User (alias = 'new', email = 'shlia@isoftstone.com', emailencodingkey='UTF-8', lastname = 'Testing', languagelocalekey = 'en_US', localesidkey='en_US', profileid = p.id, timezonesidkey = 'Asia/Shanghai', username='new3@testorg1.com');
        insert u3;
        User u2 =new User (alias = 'new', email = 'shlia@isoftstone.com', emailencodingkey='UTF-8', lastname = 'Testing', languagelocalekey = 'en_US', localesidkey='en_US', profileid = p.id, timezonesidkey = 'Asia/Shanghai', username='new@testorg1.com',managerid=u3.id);
        insert u2;
        
        User u1 =new User (alias = 'standt', email = 'shlia@isoftstone.com', emailencodingkey='UTF-8', lastname = 'Testing', languagelocalekey = 'en_US', localesidkey='en_US', profileid = p.id, timezonesidkey = 'Asia/Shanghai', username='standarduser@testorg1.com',managerid=u2.id);
        insert u1;
        
       System.runAs(u1) {
           hospital__c hp=new hospital__c(name='testhospital',Nickname__c='testnick', approvalstatus__c='审批通过',active__c=true);
           insert hp;
           
           
           String rtid;
           String hcprtid;
           RecordType rt=new recordtype();
           RecordType hcprt=new recordtype();
         
           hcprt=[select id from recordtype where sobjecttype=:'HCPEducation__c' and name=:'学术沙龙'];
           rt=[select id from recordtype where sobjectType=:'NationalAttendee__c' and name=:'学术沙龙']; 
           hcprtid=hcprt.id;
         
           HCP__c hcp1=new hcp__c(Name='testhcp1',Hospital__c=hp.id,Active__c=true,class2__c='决策人(DM)');
           insert hcp1;
           HCP__c hcp2=new hcp__c(Name='testhcp2',Hospital__c=hp.id,Active__c=true,class2__c='决策人(DM)');
           insert hcp2;    

           HCPEducation__c hcpedu=new HCPEducation__c(ownerid = u2.id,name='testsaloon',date__c=date.today()+30 ,recordtypeid=hcprtid, NOC__c=20,soc__c=20,eoc__c=20,woc__c=20,place__c='asdf');             //create a saloon type record;
           insert hcpedu;
           recordtype rgrt=[select id from recordtype where sobjecttype=:'place__c' and name=:'region'];
           Place__c rgl=new  Place__c();
           rgl.name='华南区';
           rgl.recordtypeid=rgrt.id;
           rgl.ownerid = u1.id;
           insert rgl;
           
                      Place__c rgl1=new  Place__c();
           rgl1.name='华东区';
           rgl1.recordtypeid=rgrt.id;
           rgl1.ownerid = u1.id;
           insert rgl1;
           
                      Place__c rgl2=new  Place__c();
           rgl2.name='华西区';
           rgl2.recordtypeid=rgrt.id;
           rgl2.ownerid = u1.id;
           insert rgl2;
           
                      Place__c rgl3=new  Place__c();
           rgl3.name='华北区';
           rgl3.recordtypeid=rgrt.id;
           rgl3.ownerid = u1.id;
           insert rgl3;
        
           RegionNameList__c rnl=new RegionNameList__c(ownerid = u1.id,HCPEducation__c=hcpedu.id,name='华南区名单',region__c=rgl.id,TargetNo__c=20);
           insert rnl;
           
           citynamelist__c cnl=new citynamelist__c(ownerid = u1.id,RegionNameList__c=rnl.id,name='广州',TargetNo__c=20);
           insert cnl;

           RegionNameList__c rnl1=new RegionNameList__c(ownerid = u1.id,HCPEducation__c=hcpedu.id,name='华东区名单',region__c=rgl1.id,TargetNo__c=20);
           insert rnl1;
           
           citynamelist__c cnl1=new citynamelist__c(ownerid = u1.id,RegionNameList__c=rnl1.id,name='广州',TargetNo__c=20);
           insert cnl1;

           RegionNameList__c rnl2=new RegionNameList__c(ownerid = u1.id,HCPEducation__c=hcpedu.id,name='华西区名单',region__c=rgl2.id,TargetNo__c=20);
           insert rnl2;
           
           citynamelist__c cnl2=new citynamelist__c(ownerid = u1.id,RegionNameList__c=rnl2.id,name='广州',TargetNo__c=20);
           insert cnl2;

           RegionNameList__c rnl3=new RegionNameList__c(ownerid = u1.id,HCPEducation__c=hcpedu.id,name='华北区名单',region__c=rgl3.id,TargetNo__c=20);
           insert rnl3;
           
           citynamelist__c cnl3=new citynamelist__c(ownerid = u1.id,RegionNameList__c=rnl3.id,name='广州',TargetNo__c=20);
           insert cnl3;    
                                        
           hcpedu.NOC__c=0;
           update hcpedu;
           
                      hcpedu.soc__c=0;
           update hcpedu;
           
                      hcpedu.eoc__c=0;
           update hcpedu;
           
                      hcpedu.woc__c=0;
           update hcpedu;
           
          // delete hcpedu;
               
        }
    
    }
}